package cn.doitedu.api;

import org.apache.flink.api.common.functions.MapFunction;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

/**
 * @Author: 深似海
 * @Site: <a href="www.51doit.com">多易教育</a>
 * @QQ: 657270652
 * @Date: 2024/2/28
 * @Desc: 学大数据，上多易教育
 *
 *    union算子演示
 **/
public class _30_Union_Demo {

    public static void main(String[] args) {

        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        env.setParallelism(1);
        env.enableCheckpointing(5000);
        env.getCheckpointConfig().setCheckpointStorage("file:///d:/ckpt");

        // o1,2024-02-28 11:22:30.200
        DataStreamSource<String> stream1 = env.socketTextStream("doitedu", 8891);


        // {"order_id":"o1","create_time":1709091150000}
        DataStream<String> stream2 = env.socketTextStream("doitedu", 8892);


        // union 只能合并同类型的多个流
        stream1.union(stream2)
                .map(new MapFunction<String, GlobalBean>() {
                    @Override
                    public GlobalBean map(String value) throws Exception {


                        return null;
                    }
                });



    }



}
